# Check if cmake has the required version
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

# Set name of our project to Cold Pig. To be done after check of cmake version
project(ColdPig)

# Set ColdPig variables
set(COLDPIG $ENV{COLDPIG})
set(COLDPIG_TARGET $ENV{COLDPIG_TARGET})
set(COLDPIG_COMPILE $ENV{COLDPIG_COMPILE})

# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

# Setup ROOT
find_package(ROOT 5.0.0 REQUIRED)

find_package(GSL REQUIRED)
include_directories(${GSL_INCLUDE_DIRS} ${GSLCBLAS_INCLUDE_DIRS})
set(LIBS ${LIBS} ${GSL_LIBRARIES} ${GSLCBLAS_LIBRARIES})


include(ColdPigMacros)

# Check if the user wants to build the project in the source directory
Check_out_of_Source_Build()

# Setup system dependent flags
SetupSystem()

if (${COLDPIG})
  set(COLDPIG_INSTALL_DIR ${COLDPIG})
else (${COLDPIG})
  set(COLDPIG_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
endif (${COLDPIG})

# set(COLDPIG_INSTALL_DIR "${COLDPIG}/${COLDPIG_TARGET}")
# set(COLDPIG_LIBRARIES "${COLDPIG}/${COLDPIG_TARGET}")

set(COLDPIG_MAJOR_VERSION 0)
set(COLDPIG_MINOR_VERSION 1)
set(COLDPIG_PATCH_VERSION 50)
set(COLDPIG_VERSION "${COLDPIG_MAJOR_VERSION}.${COLDPIG_MINOR_VERSION}.${COLDPIG_PATCH_VERSION}")
set(COLDPIG_LIBRARY_PROPERTIES ${COLDPIG_LIBRARY_PROPERTIES}
    VERSION "${COLDPIG_VERSION}"
    SOVERSION "${COLDPIG_MAJOR_VERSION}"
    SUFFIX ".so"
)

add_subdirectory(BASE)
add_subdirectory(PHYSICS)
add_subdirectory(SIM)
add_subdirectory(EVE)
add_subdirectory(coldpig)

include(CPack)

Message(STATUS "Coldpig will be installed in ${CMAKE_INSTALL_PREFIX}") 

# include(CTest)
